Using nbtutor

In class at times you might see me use a Jupyter extension called nbtutor to help visualise what is happening.

If you would like to use nbtutor yourself you need to install it.

Installing nbtutor

To do this:

  • On Windows open Anaconda prompt
  • On Mac OSX open terminal

type the following:

pip install nbtutor

press Enter and it should download.

Using nbtutor

In Jupyter, include the following in a cell to load nbtutor: %load_ext nbtutor


In [1]:
%load_ext nbtutor

Then to use it in any given cell type: %%nbtutor. Here is an example:


In [2]:
%%nbtutor

cumulative_sum = 0
for i in range(10):
    cumulative_sum += i


This will display an interactive environment that looks like the following picture:

You can click on next to step through the code whilst visualising what it is doing, you can also change the dropdown box from Memory to Timeline.

  • Memory: shows what Python has in memory and what pointers are being used at any given point in time;
  • Timeline: shows the various objects over time.

If you would like to read the documentation for nbtutor you can find it here: https://nbtutor.readthedocs.io/en/